package com.geo.geotool.controller;

import com.geo.geotool.base.entity.RetEntity;
import com.geo.geotool.base.entity.RetResponse;
import com.geo.geotool.entity.enmu.GeoFormatEnum;
import com.geo.geotool.entity.geo.GeoFileInfo;
import com.geo.geotool.service.IGeoFileService;
import com.geo.geotool.service.geofile.ShapeFileParser;
import com.geo.geotool.service.trans.GeometryFormatCapture;
import com.geo.geotool.service.trans.GeometryFormatTrans;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.HashMap;
import java.util.Map;

/**
 * • @Description: 地理文件解析
 * • @author  : yell
 * • @date : 2021/11/24  11:16
 */
@RestController
@RequestMapping("/gisData")
@Slf4j
public class GisDataController {
    @RequestMapping("/regData")
    @ResponseBody
    public RetEntity regData(@RequestBody Map data) throws Exception{
        String regData = (String) data.get("regData");
        return RetResponse.makeOKRsp(GeometryFormatCapture.capture(regData));
    }

    @RequestMapping("/dataTrans")
    @ResponseBody
    public RetEntity dataTrans(@RequestBody Map data) throws Exception{
        String gisData = (String) data.get("data");
        String format = (String)data.get("toFormat");
        GeometryFormatTrans geometryFormatTrans = new GeometryFormatTrans();
        geometryFormatTrans.geoFormatTrans(gisData,GeometryFormatCapture.capture(gisData),format);
        return RetResponse.makeOKRsp( geometryFormatTrans.geoFormatTrans(gisData,GeometryFormatCapture.capture(gisData),format));
    }
}
